import 'package:flutter/material.dart';
import 'package:flutter_eve_plugin/components/main/app_bar.dart';
import 'package:flutter_eve_plugin/route/main.dart';
import 'package:flutter_eve_plugin/store/main.dart';
import 'package:flutter_eve_plugin/store_vm/app_vm.dart';
import 'package:flutter_eve_plugin/store_vm/ye_xiu/login/main.dart';
import 'package:flutter_eve_plugin/store_vm/ye_xiu/main.dart';
import 'package:flutter_eve_plugin/utils/image_util.dart';
import 'package:flutter_eve_plugin/utils/screen_util.dart';
import 'package:flutter_redux/flutter_redux.dart';

class LoginSelectMachinePage extends StatefulWidget {
  final String title;

  LoginSelectMachinePage({Key key, this.title}) : super(key: key);

  @override
  _LoginSelectMachinePageState createState() => _LoginSelectMachinePageState();
}

class _LoginSelectMachinePageState extends State<LoginSelectMachinePage> {
  @override
  Widget build(BuildContext context) {
    return StoreConnector<AppState, AppStateViewModel>(converter: (store) {
      return AppStateViewModel(
          state: store.state,
          yeXiuStateViewModel: YeXiuStateViewModel(
              loginStateViewModel:
                  LoginStateViewModel(selectMachine: (type) {
                    switch(type){
                      case 0:
                        break;
                      case 1:
                        Navigator.pushNamed(context, RouteConstant.LoginBootMachinePage);
                        break;
                    }
                  })));
    }, builder: (context, vm) {
      return Scaffold(
        backgroundColor: Colors.white,
        appBar: buildAppBar(context,
            type: FigureIP.YE_XIU, colors: [Colors.white, Colors.white]),
        body: Container(
          height: MediaQuery.of(context).size.height,
          width: MediaQuery.of(context).size.width,
          child: Column(
            mainAxisAlignment: MainAxisAlignment.start,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: <Widget>[
              Container(
                padding: EdgeInsets.only(left: setRatio(30), top: setRatio(20)),
                child: Text(
                  '你有机器吗？',
                  style: TextStyle(
                      fontSize: setTextSp(24),
                      color: Color((0xFF333333)),
                      fontWeight: FontWeight.bold),
                ),
              ),
              GestureDetector(
                onTap: () =>
                    vm.yeXiuStateViewModel.loginStateViewModel.selectMachine(1),
                child: Container(
                  margin:
                      EdgeInsets.only(left: setRatio(125), top: setRatio(71)),
                  width: setRatio(124),
                  height: setRatio(124),
                  decoration: BoxDecoration(
                      color: Color(0xFFF6F6F6),
                      borderRadius: BorderRadius.circular(setRatio(62))),
                  child: Center(
                    child: Text(
                      '有',
                      style: TextStyle(
                          color: Color(0xFF333333), fontSize: setTextSp(23)),
                    ),
                  ),
                ),
              ),
              GestureDetector(
                onTap: () =>
                    vm.yeXiuStateViewModel.loginStateViewModel.selectMachine(0),
                child: Container(
                  margin:
                      EdgeInsets.only(left: setRatio(125), top: setRatio(30)),
                  width: setRatio(124),
                  height: setRatio(124),
                  decoration: BoxDecoration(
                      color: Color(0xFFF6F6F6),
                      borderRadius: BorderRadius.circular(setRatio(62))),
                  child: Center(
                    child: Text(
                      '没有',
                      style: TextStyle(
                          color: Color(0xFF333333), fontSize: setTextSp(23)),
                    ),
                  ),
                ),
              ),
              Expanded(child: Container()),
              Container(
                padding: EdgeInsets.only(bottom: setRatio(20)),
                child: Center(
                  child: Text(
                    '关于琥珀音箱',
                    style: TextStyle(
                        color: Color(0xFF038AFF), fontSize: setTextSp(13)),
                  ),
                ),
              )
            ],
          ),
        ),
      );
    });
  }
}
